package us.sunrisemorning.pixivbrower;

import java.io.IOException;

import com.jfinal.server.undertow.UndertowServer;

import us.sunrisemorning.pixivbrower.web.WebConfig;

public class Main {
    public static void main(String[] args) {
        UndertowServer server = UndertowServer.create(WebConfig.class);
        server.setHost("127.0.0.1");
        
        if (args.length >= 1) {
            try {
                int port = Integer.valueOf(args[0]);
                server.setPort(port);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        
        server.start();
        
        try {
            Runtime.getRuntime().exec("cmd /c start http://" + server.getUndertowConfig().getHost() + ":" + server.getUndertowConfig().getPort());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
